package com.blb.demo4;

import java.io.*;

/**
 * IO操作工具类
 */
public class IOUtils {

    /**
     * 流字节数据的复制
     * @param input
     * @param output
     */
    public static void copy(InputStream input, OutputStream output) throws IOException {
        byte[] buffer = new byte[1024];
        int length = 0;
        //一边从输入流读取字节
        while((length = input.read(buffer)) != -1){
            //一边写入到输出流
            output.write(buffer,0,length);
        }
        output.flush();
    }

    public static void main(String[] args) {
        try {
            IOUtils.copy(new FileInputStream("D:\\install\\apache-jmeter-5.4.1.zip"),
                    new FileOutputStream("D:\\apache-jmeter-5.4.1.zip"));
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
